import xadmin

from apps.operations.models import *


# 用户咨询
class UserAskAdmin(object):
    # 显示字段
    list_display = ['name', 'phone', 'course_name']
    # 用于搜索的字段
    search_fields = ['name', 'phone', 'course_name']
    # 用于筛选的字段
    list_filter = ['name', 'phone', 'course_name']
    # 可直接编辑的字段
    list_editable = ['name', 'phone', 'course_name']
    # 侧边栏图标
    model_icon = 'fa fa-sticky-note-o'


# 用户评论
class CourseCommentsAdmin(object):
    # 显示字段
    list_display = ['user', 'course']
    # 用于搜索的字段
    search_fields = ['user', 'course']
    # 用于筛选的字段
    list_filter = ['user__username', 'course__name']
    # 可直接编辑的字段
    list_editable = ['user', 'course']
    # 侧边栏图标
    model_icon = 'fa fa-commenting-o'


# 用户收藏
class UserFavoritesAdmin(object):
    # 显示字段
    list_display = ['user', 'fav_id', 'fav_type']
    # 用于搜索的字段
    search_fields = ['user', 'fav_id', 'fav_type']
    # 用于筛选的字段
    list_filter = ['user__username', 'fav_id', 'fav_type']
    # 可直接编辑的字段
    list_editable = ['user', 'fav_id', 'fav_type']
    # 侧边栏图标
    model_icon = 'fa fa-star-o'


# 用户消息
class UserMessageAdmin(object):
    # 显示字段
    list_display = ['user', 'has_read']
    # 用于搜索的字段
    search_fields = ['user', 'has_read']
    # 用于筛选的字段
    list_filter = ['user__username', 'has_read']
    # 可直接编辑的字段
    list_editable = ['user', 'has_read']
    # 侧边栏图标
    model_icon = 'fa fa-bell-o'


# 用户课程
class UserCourseAdmin(object):
    # 显示字段
    list_display = ['user', 'course']
    # 用于搜索的字段
    search_fields = ['user', 'course']
    # 用于筛选的字段
    list_filter = ['user__username', 'course__name']
    # 可直接编辑的字段
    list_editable = ['user', 'course']
    # 侧边栏图标
    model_icon = 'fa fa-pencil-square-o'


# 将数据表注册到管理界面
xadmin.site.register(UserAsk, UserAskAdmin)
xadmin.site.register(CourseComments, CourseCommentsAdmin)
xadmin.site.register(UserFavorites, UserFavoritesAdmin)
xadmin.site.register(UserMessage, UserMessageAdmin)
xadmin.site.register(UserCourse, UserCourseAdmin)
